<template>
    <div class="user">
        <img src="../assets/images/top.png" alt="" class="bg">
        <ul class="info">
            <li class="text">
                <div class="nickname">{{ info.nickname }}</div>
                <div class="phone-text">
                    <van-icon name="phone-circle-o" />
                    <span class="phone">{{ info.phone }}</span>
                </div>
                <button class="btn">重新绑定</button>
            </li>
            <img :src="info.headimgurl" alt="" class="avater">
        </ul>
        <!-- 添加 -->
        <div class="option-list">
            <span class="text">
                我的使用人
            </span>
            <buttin class="button" @click="add">
                <span>添加使用人</span>
                <van-icon name="plus" />
            </buttin>
        </div>

        <!-- 使用人 -->
        <ul class="user-list">
            <li class="item" v-for="(item, index) in list " :key="index">
                <div class="title">使用人1</div>
                <div class="infomation">
                    <img src="../assets/images/icon.png" alt="" class="img">
                    <ul class="text-list">
                        <li class="text">使用人姓名：{{ item.truename }}</li>
                        <li class="text">使用人性别：男</li>
                        <li class="text">使用人手机：{{ item.phone }}</li>
                        <li class="text">使用人SN：{{ item.code }}</li>
                    </ul>
                </div>
                <!-- <ul class="icon-list">
                    <li class="icon-item">
                        <img src="../assets/images/icon1.png" alt="" class="icon-img">
                        <span>设为默认</span>
                    </li>
                    <li class="icon-item">
                        <img src="../assets/images/icon2.png" alt="" class="icon-img">
                        <span>分享对象</span>
                    </li>
                    <li class="icon-item">
                        <img src="../assets/images/icon3.png" alt="" class="icon-img">
                        <span>报警设置</span>
                    </li>
                </ul> -->
            </li>

        </ul>
        <!-- 常用功能 -->
        <div class="common-function">
            <div class="title">常用功能</div>
            <ul class="content">
                <!-- 隐私政策 -->
                <li class="item">
                    <img src="../assets/images/icon-1.png" alt="" class="img">
                    <span class="text">隐私政策</span>
                </li>
                <!-- 免责声明 -->
                <li class="item">
                    <img src="../assets/images/icon-2.png" alt="" class="img">
                    <span class="text">免责声明</span>
                </li>
                <!-- 产品介绍 -->
                <li class="item">
                    <img src="../assets/images/icon-3.png" alt="" class="img">
                    <span class="text">产品介绍</span>
                </li>
                <!-- 使用帮助 -->
                <li class="item">
                    <img src="../assets/images/icon-4.png" alt="" class="img">
                    <span class="text">使用帮助</span>
                </li>
                <!-- 用户协议 -->
                <li class="item">
                    <img src="../assets/images/icon-5.png" alt="" class="img">
                    <span class="text">用户协议</span>
                </li>
                <!-- 配网说明 -->
                <li class="item">
                    <img src="../assets/images/icon-6.png" alt="" class="img">
                    <span class="text">配网说明</span>
                </li>
            </ul>
        </div>
    </div>
</template>

<script>


import { myInfo } from "../api/users";
import { DeviceList } from "../api/device";
export default {
    data() {
        return {
            selecterShow: false,
            info: {},
            list: [],

        };
    },
    components: {
        // LineChart
    },
    methods: {
        add() {
            this.$router.push({
                name: 'adduser'
            })

        },
        change() {
            this.selecterShow = !this.selecterShow;
        },
        async getReport() {
            var token = localStorage.getItem("token");
            var obj = await myInfo({ token: token });
            if (obj.status == 200) {
                this.info = obj.data;
            }
        },
        async getDevice() {
            var token = localStorage.getItem("token");
            var obj = await DeviceList({ token: token });
            if (obj.status == 200) {
                this.list = obj.data;
            }
        }
    },
    created() {
        this.getReport();
        this.getDevice();
    },
};
</script>

<style lang="scss" scoped>
.user {
    width: 750px;
    background-color: #0C0C0C;
    padding-bottom: 30px;
    height: 100vh;

    .bg {
        width: 750px;
        height: 460px;
        position: absolute;
    }

    .info {
        position: relative;

        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 50px;
        height: 182px;
        color: #fff;
        padding-top: 80px;
        height: 260px;

        .text {

            .nickname {
                font-size: 45px;
            }

            .phone-text {
                margin-top: 30px;
                font-size: 35px;

                .phone {
                    margin-left: 20px;
                }
            }

            .btn {
                background-color: #EB4EF6;
                width: 140px;
                height: 40px;
                border-radius: 10px;
                color: #fff;
                font-size: 26px;
                display: flex;
                align-items: center;
                justify-content: center;
                margin-top: 20px;

            }
        }

        .avater {
            width: 230px;
            height: 230px;
            border-radius: 50%;
        }
    }

    .option-list {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 690px;
        color: #fff;
        margin: 20px auto;
        margin-top: 150px;

        .text {
            font-size: 26px;
            font-weight: bold;
        }

        .button {

            border: 1px solid #C5C1E2;
            font-size: 22px;
            height: 38px;
            color: #C5C1E2;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 30px;
            padding: 0 10px;

        }

    }

    .user-list {
        width: 750px;

        .item {
            background-color: #40225E;
            width: 690px;
            margin: 30px;
            border-radius: 16px;
            padding: 30px;
            box-sizing: border-box;

            .title {
                color: #9D98B7;
                font-size: 20px;
                font-weight: bold;
                line-height: 50px;
            }

            .infomation {
                display: flex;
                margin-top: 10px;

                .img {
                    width: 150px;
                    height: 150px;
                    border-radius: 16px;
                    margin-right: 25px;
                }

                .text-list {
                    font-size: 20px;
                    color: #Fff;
                    line-height: 2em;
                    font-weight: bold;

                    .text {
                        text-overflow: ellipsis;
                        overflow: hidden;
                        max-width: 410px;
                        white-space: no-wrap;
                    }
                }
            }

            .icon-list {
                display: flex;
                margin-top: 30px;

                .icon-item {
                    display: flex;
                    align-items: center;
                    color: #9784B5;
                    font-size: 20px;
                    font-weight: bold;
                    margin-right: 50px;

                    .icon-img {
                        width: 33px;
                        height: 33px;
                        margin-right: 10px;
                    }

                }
            }
        }
    }

    .common-function {
        background-color: #40225E;
        width: 690px;
        margin: 30px;
        border-radius: 16px;
        padding: 30px;
        box-sizing: border-box;

        .title {
            color: #9D98B7;
            font-size: 20px;
            font-weight: bold;
            line-height: 50px;
        }

        .content {
            display: flex;
            flex-wrap: wrap;

            .item {
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;
                width: 140px;
                height: 150px;
                margin-bottom: 20px;

                .img {
                    width: 82px;
                    height: 82px;
                    border-radius: 50%;
                }

                .text {
                    color: #9D98B7;
                    font-size: 20px;
                    font-weight: bold;
                    margin-top: 15px;
                }
            }

        }


    }
}
</style>